import 'package:flutter/material.dart';

class Test_Clip extends StatelessWidget {
  const Test_Clip({super.key});
  @override
  Widget build(BuildContext context) {
    Widget avatar = Image.asset("assets/avatar.jpg", width: 60.0);
    return Scaffold(
        appBar: AppBar(
          title: const Text('Test_Clip'),
        ),
        body: Column(children: [
          avatar,
          ClipOval(child: avatar),
          ClipRRect(
            child: avatar,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              Align(
                alignment: Alignment.topLeft,
                widthFactor: .5,//宽度设为原来宽度一半，另一半会溢出
                child: avatar,
              ),
              const Text("你好世界", style: TextStyle(color: Colors.green))

            ],
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              ClipRect(//将溢出部分剪裁
                child: Align(
                  alignment: Alignment.topLeft,
                  widthFactor: .5,//宽度设为原来宽度一半
                  child: avatar,
                ),
              ),
              const Text("你好世界",style: TextStyle(color: Colors.green))
            ],
          ),
        ]));
  }
}
